package com.sqx.modules.course.controller.app;

import com.sqx.common.utils.Result;
import com.sqx.modules.app.annotation.Login;
import com.sqx.modules.course.service.AdsUnlockVideosService;
import com.sqx.modules.sys.controller.AbstractController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(value = "短视频广告解锁视频", tags = {"短视频广告解锁视频"})
@RequestMapping(value = "/app/adsUnlockVideos")
public class AppAdsUnlockVideosController extends AbstractController {

    @Autowired
    private AdsUnlockVideosService adsUnlockVideosService;

    /**
     * 观看广告
     * @param userId 用户id
     * @param courseDetailsId 短剧剧集id
     * @param adsId 广告id
     * @return 短剧广告解锁记录信息
     */
    @Login
    @PostMapping("/watchAds")
    @ApiOperation("观看广告")
    public Result watchAds(@RequestAttribute("userId")Long userId,@ApiParam("短剧剧集id")Long courseDetailsId,@ApiParam("广告id")Long adsId){
        return adsUnlockVideosService.watchAds(userId,courseDetailsId,adsId);
    }

    /**
     * 解锁剧集
     * @param userId 用户id
     * @param unlockCourseId 短剧广告解锁记录id
     * @param status 退出广告时第三方返回的状态
     * @return
     */
    @Login
    @PostMapping("/unlockCourseDetails")
    @ApiOperation("解锁剧集")
    public Result unlockCourseDetails(@RequestAttribute("userId")Long userId, @ApiParam("短剧广告解锁记录id")Long unlockCourseId, @ApiParam("第三方返回的观看状态")Integer status){
        Boolean bool = adsUnlockVideosService.unlockCourseDetails(userId,unlockCourseId,status);
        return Result.success().put("data",bool);
    }

    @Login
    @GetMapping("/selectAds")
    @ApiOperation("查询广告")
    public Result selectAds(@RequestAttribute("userId")Long userId){
        return adsUnlockVideosService.selectAds(userId);
    }


    @Login
    @GetMapping("/courseDetailsSelect")
    @ApiOperation("查询剧集")
    public Result courseDetailsSelect(@RequestAttribute("userId")Long userId){
        return adsUnlockVideosService.courseDetailsSelect(userId);
    }

}
